#pragma once

#include <QtGui/QGraphicsPathItem>
class QtGraphicsStateItem;
class QtGroupBoxPropertyBrowser;
class QtVariantPropertyManager;
class QtVariantProperty;
#include <QtCore/QEasingCurve>

class QtGraphicsLinkItem : public QObject, public QGraphicsPathItem
{
	Q_OBJECT
public:
	QtGraphicsLinkItem(QGraphicsItem* parent = 0);
	virtual ~QtGraphicsLinkItem(void);

	virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget  = 0);

	void setLinks(QtGraphicsStateItem* stateItem1, QtGraphicsStateItem* stateItem2);
	const QtGraphicsStateItem* getBeginState() const { return mStateItem1; }
	const QtGraphicsStateItem* getEndState() const { return mStateItem2; }
	qreal getAnimTime() const ;
	QEasingCurve::Type getAnimType() const;

	void createPropertyWidget();
	QtGroupBoxPropertyBrowser* getPropertyWidget() const { return mPropertyWidget; }


	friend QDataStream & operator << (QDataStream &dataStream, QtGraphicsLinkItem &itemBase);
	friend QDataStream & operator >> (QDataStream &dataStream, QtGraphicsLinkItem &itemBase);
	virtual void save(QDataStream &dataStream);
	virtual void load(QDataStream &dataStream);

public slots:
	void pathChanged();
private:
	QtGraphicsStateItem* mStateItem1;
	QtGraphicsStateItem* mStateItem2;

	QtGroupBoxPropertyBrowser* mPropertyWidget;
	QtVariantPropertyManager* mVariantManager;

	QtVariantProperty* mTimeProperty;
	QtVariantProperty* mAnimType;
	QSize              mIconSize;
	QMap<int, QIcon>   mCurveIcons;
	QStringList		   mCurveNames;

	void createCurveIcons();
};
